# coding= utf-8
import sys


def getVariables():
    """
    """
    if "-i" not in sys.argv and "--include" not in sys.argv:
        i = "uatAND"
    else:
        i = sys.argv[sys.argv.index("-i") + 1] if "-i" in sys.argv else sys.argv[sys.argv.index("--include") + 1]

    if "sit" in i.split("AND"):
        # test environment      OCMS测试环境URL
        DICT__variables = {
            # "ocms_login_url": "http://10.0.180.221:4329/account/login",
        }
    elif "uat" in i.split("AND"):
        # pre environment       OCMS预发布环境URL
        DICT__variables = {
            "ocms_login_url": "https://uatocmscdp.crb.cn/crb-fbasedata-sec/#/login",
            "login_username": "gesong3fzqy",
            "login_password": "ocms@OCMS",
            "customer_name":"何三坤"
        }
    else:
        # production environment    OCMS生产环境URL
        DICT__variables = {
            "ocms_login_url": "https://jxs.crb.cn/crb-fbasedata-sec/#/login",
        }

    # 全局变量，不区分运行环境
    ####################################################################################################################
    #                                                  Elements                                                        #
    ####################################################################################################################
    DICT__variables['username_input'] = ('css selector', 'input[name="username"]')
    DICT__variables['password_input'] = ('css selector', 'input[name="password"]')
    DICT__variables['logo_image'] = ('css selector', 'img[class="title"]')
    DICT__variables['pwd_login_btn'] = ('xpath', '//span[contains(text(),"密码登录")]')
    DICT__variables['verificationCode_input'] = ('css selector', 'input[name=verificationCode]')
    DICT__variables['button_login'] = ('tag name', 'button')
    DICT__variables['orderManage_li'] = ('xpath', '//span[contains(text(),"渠道订单管理")]')
    DICT__variables['title_text'] = ('css selector', 'div[class="logo"]')
    DICT__variables['orderCenter_li'] = ('xpath', '//span[contains(text(),"订单中心")]')
    DICT__variables['orderAssist_li'] = ('xpath', '//span[contains(text(),"协助经销商报单")]')
    DICT__variables['customerCode_input'] = ('css selector','input[placeholder="客户编码"]')
    DICT__variables['orderType_input'] = ('css selector','input[placeholder="请选择订单类型"]')
    # DICT__variables['pwd_login_btn'] = ('xpath','//*[@id="app"]/div/form/div[1]/div/span[1]')
    # DICT__variables['getOrder_list_url'] = '/crb-order-api-sec/admin-helpCustomerOrder/getOrderList'

    # # 元素总集
    # elements = {}
    # # 按页面放置不同的元素集
    # login_page = {
    #     "username": "id=UserName",
    #     "password": "id=Password",
    #     "login_button": "id=saveex"
    # }
    # menu = {
    #     "role_check": "id=PostNm",
    #     "xszc": "link_text=销售政策",
    #     "fagl": "link_text=方案管理"
    # }
    # sale_policy = {
    #     # 方案页
    #     "add_fa_button": "id=add",
    #     "plan_title": "id=PlanTitle",
    #     "flow_type": "id=FlowType",
    #     "plan_content": "id=PlanContent",
    #     "PolicyObject": "id=PolicyObject",
    #     "level_one": "id=Level1",
    #     "level_two": "id=Level2",
    #     "template": "id=Template",
    #     "add_protocol_button": "id=AddProtocol",
    #     # 政策页
    #     "policy_title": "id=PolicyTitle",
    #     "start_time": "id=StartOn",
    #     "end_time": "id=EndOn",
    #     "line_cd": "id=lineCD",
    #     "charge_control_mode": "id=ChargeControlMode",
    #     "xyzd_used": "id=IsXYZDUsed",
    #     "need_predict_saleCount": "id=IsNeedPredictSaleCount",
    #     "policy_desc": "id=PolicyDesc",
    #     "to_choose_dealers": "id=min",
    #     "choose_organization": "id=BenefitBrand",
    #     "organization_fyl": "css_selector=#treeDemo_2_check",
    #     "choose_dealers": "id=PlaceTypeCD",
    #     "dealers_fyl": "css_selector=#treeDemo1_37_check",
    #     "save_tree_button": "id=btn_save_tree",
    #     "terminal_num": "id=TMNNm",
    #     "product_choose_button": "//div[@id='div_dt']/div/div/div",
    #     "product_select": "u'(.//*[normalize-space(text()) and normalize-space(.)='活动产品'])[1]/following::button[2]'",
    #     "product_save": "//table[@id='table_product']/tbody/tr[5]/td/a",
    #     "product_save_button": "id=btn_save_product",
    #     "unit price": "//table[@id='pcTable']/tbody/tr/td[6]/input",
    #     "sale_count": "//table[@id='pcTable']/tbody/tr/td[7]/input",
    #     "save_policy_button": "u'(.//*[normalize-space(text()) and normalize-space(.)='保存成功！'])[1]/following::button[1]'",
    #     "submit_plan_button": "id=submit",
    #     "audit_checkbox": "id=step_b878fc37-0ad8-42e2-9e93-bf9174ad7291",
    #     "choose_box": "//*[@id=‘table_flow_send_step’]/tbody/tr[23]/td/input[3]",
    #     "search_approver_text": "id=searchtext",
    #     "search_approver_button": "u'//input[@value='查询']'",
    #     "select_approver_value": "//div[@id='roadui_tree_0010081535|50000809|Z074']/ul/li[3]/span/span",
    #     "save_approver_button": "//button[@onclick='confirm1();']",
    #     "save_audit_button": "name=Save"
    # }
    # elements['login_page'] = login_page
    # elements['menu'] = menu
    # elements['sale_policy'] = sale_policy
    # # 添加公共元素到全局变量
    # DICT__variables['elements'] = elements

    return DICT__variables
